home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 July: Mac OS SDK / Dev.CD Jul 97 SDK2.toast / Development Kits (Disc 2) / ScriptX / Documentation / Code Examples from Docs / compguid / animatin / animshp2.sx < prev   
Encoding:
Text File  |  1996-05-21  |  1.9 KB  |  69 lines  |  [TEXT/ttxt]

  1. --<<<-
  2. -- Filename: ANIMSHP2.SX
  3.  
  4. -- Other Files Required: (none)
  5.  
  6. -- Purpose: To demonstrate how animation works using 
  7. --     TargetListAction to change the targets in the list
  8.  
  9. -- Specialized Classes: (none)
  10.  
  11. -- Instructions to User: Load this file; it displays a window,
  12. --     which is initially empty, then displays a 2D shape that 
  13. --       changes from a cirle to a rounded rectangle to a rectangle.
  14. --     To start again, type: "goToBegin alp"
  15.  
  16. -- Author: Douglas Kramer
  17.  
  18. ------------------------------------------------------------------------ 
  19.  
  20. -- Create a window
  21. global myWindow := new Window boundary:(new Rect x2:200 y2:200)
  22. myWindow.y := 40
  23. show myWindow
  24.  
  25. -- Create the ActionList and ActionListPlayer
  26. global al := new ActionList
  27. global alp := new ActionListPlayer actionList:al scale:30 targetCount:24
  28. alp.authorData := myWindow
  29.  
  30. -- Script to create a blue circle
  31. function createCircle action target player -> 
  32.    (
  33.       local myShape := new TwoDShape target:(new Oval x2:80 y2:80) 
  34.       myShape.fill := new Brush color:blueColor
  35.       myShape.x := 60
  36.       myShape.y := 60
  37.       append player.authorData myShape
  38.       myShape
  39.    )
  40.  
  41. function emptyOutTargets action target player -> 
  42.     (
  43.         emptyOut player.authorData
  44.         emptyOut player.targets
  45.     ) 
  46.  
  47. -- Set action to create and add the circle to the targets
  48. global addCircleToTargets := new TargetListAction targetNum:1 time:1 \
  49.                     script:createCircle rewindScript:emptyOutTargets
  50.  
  51. -- Set an action to change its shape
  52. global makeRoundRect := new ShapeAction targetNum:1 time:30 \
  53.                                 shape:(new RoundRect x2:80 y2:80 rx:30 ry:30)
  54.  
  55. -- Set another action to change its shape
  56. global makeRect := new ShapeAction targetNum:1 time:60 \
  57.                                 shape:(new Rect x2:80 y2:80)
  58.  
  59. -- Append actions to the ActionList
  60. append al addCircleToTargets
  61. append al makeRoundRect
  62. append al makeRect
  63.  
  64. -- Play the ActionListPlayer
  65. play alp
  66.  
  67. -- To play again, type: goToBegin alp
  68.  
  69.